import Loadable from 'react-loadable';

const Loading = () => {
    return (<span>loading......</span>);
}

const Login = Loadable({
    loader: () => import('../views/login'),
    loading: Loading,
});

const Home = Loadable({
    loader: () => import('../views/home'),
    loading: Loading,
});

//----------------------home页下的二级路由
//岗位
const Post = Loadable({
    loader: () => import('../views/home/post'),
    loading: Loading,
});
const PostDetails = Loadable({
    loader: () => import('../views/home/post/postDetails'),
    loading: Loading,
});
//项目
const Project = Loadable({
    loader: () => import('../views/home/project'),
    loading: Loading,
});
// 项目详情
const Prodetail = Loadable({
    loader: () => import('../views/home/prodetail'),
    loading: Loading,
});
//实训
const Training = Loadable({
    loader: () => import('../views/home/training'),
    loading: Loading,
});
//面试
const Interview = Loadable({
    loader: () => import('../views/home/interview'),
    loading: Loading,
});
//问答
const Ask = Loadable({
    loader: () => import('../views/home/ask'),
    loading: Loading,
});
//个人中心
const My = Loadable({
    loader: () => import('../views/home/my'),
    loading: Loading,
});
// 添加面试
const AddRecord = Loadable({
    loader: () => import('../views/home/interview/AddRecord/index'),
    loading: Loading,
});
// 面试详情
const DetailRecord = Loadable({
    loader: () => import('../views/home/interview/DetailRecord/index'),
    loading: Loading,
});
// 面试编辑
const EditRecord = Loadable({
    loader: () => import('../views/home/interview/EditRecord'),
    loading: Loading,
});


//-------------------------------面试下的三级路由
//面试记录
const Record = Loadable({
    loader: () => import('../views/home/interview/record'),
    loading: Loading,
});
//我的面试记录
const MyRecord = Loadable({
    loader: () => import('../views/home/interview/myRecord'),
    loading: Loading,
});
//面试排行榜
const RecordRanking = Loadable({
    loader: () => import('../views/home/interview/recordRanking'),
    loading: Loading,
});
//-----------------------------------问答下的三级路由
//问答列表
const AskList = Loadable({
    loader: () => import('../views/home/ask/askList'),
    loading: Loading,
});
//我的问答
const MyAsk = Loadable({
    loader: () => import('../views/home/ask/myAsk'),
    loading: Loading,
});

// -----------------------------------问答的二级路由
const AskDetail =  Loadable({
    loader: () => import('../views/home/ask/askDetail/index'),
    loading: Loading,
});



const routerList = [
    {
        path: "/login",
        component: Login
    },
    {
        path: "/home",
        component: Home,
        requiresAuth: true,
        children: [
            {
                from: "/home",
                to: "/home/post"
            },
            {
                path: "/home/post",
                component: Post
            },
            {
                path: "/home/postDetails",
                component: PostDetails
            },
            {
                path: "/home/project",
                component: Project
            },
            {
                path: "/home/training",
                component: Training
            },
            {
                path: "/home/my",
                component: My
            },
            {
                path: "/home/addrecord",
                component: AddRecord
            },
            {
                path: "/home/detailrecord/:id",
                component: DetailRecord
            },
            {
                path: "/home/prodetail",
                component: Prodetail
            },
            {
                path: "/home/editrecord/:id",
                component:EditRecord
            },
            {
                path: "/home/askdetail/:id",
                component:AskDetail
            },
            {
                path: "/home/interview",
                component: Interview,
                children: [
                    {
                        path: "/home/interview/record",
                        component: Record,
                    },
                    {
                        path: "/home/interview/myRecord",
                        component: MyRecord,
                    },
                    {
                        path: "/home/interview/recordRanking",
                        component: RecordRanking,
                    }
                ]
            },
            {
                path: "/home/ask",
                component: Ask,
                children: [
                    {
                        path: "/home/ask/askList",
                        component: AskList,
                    },
                    {
                        path: "/home/ask/myAsk",
                        component: MyAsk,
                    }
                ]
            }
        ]
    },
    {
        from: "/",
        to: "/login"
    }
];

export default routerList;